/**
* @author Ashish Gupta
* CVSSP, University of Surrey
* Copyright (c) 2010 Ashish Gupta
* All rights reserved.
*/
/**
 * 
 */
package uk.ac.surrey.agupta.acquisition;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import uk.ac.surrey.agupta.data.PascalVocImageSet;

/**
 * @author Ashish
 *
 */
public class ReadImageSet {
	public static void read(PascalVocImageSet imageset, String category, String dataSource) throws IOException{
		String imagesetFilename = buildFilename(category,dataSource);
		imageset.setVisualCategory(category);
		File file = new File(imagesetFilename);
		FileReader fr = new FileReader(file);
		BufferedReader br = new BufferedReader(fr);
		String line = null;
		while((line = br.readLine())!=null){
			String[] inLine = line.split("\t");
			imageset.setImageName(inLine[0]);
			imageset.setClassLabel(Integer.parseInt(inLine[1]));
		}
	}

	/**
	 * @param category
	 * @param dataSource
	 * @return
	 */
	private static String buildFilename(String category, String dataSource) {
		String imagesetFilename = dataSource+category+"_train.txt";
		return imagesetFilename;
	}
}
